package com;

import com.itheima.factory.UserServiceFactory;
import com.itheima.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Test {
    public static void main(String[] args) {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("ApplicationContext.xml");
        /*UserService service1 = (UserService) context.getBean("userService");
        UserService service2 = (UserService) context.getBean("userService");
        UserService service3 = (UserService) context.getBean("userService");
        UserService service4 = (UserService) context.getBean("userService");
        context.registerShutdownHook();
        service1.run();
        service2.run();
        service3.run();
        service4.run();*/
        //context.close();
        /**
         * 静态工厂的形式获取bean
         */
       /* UserService service = (UserService) context.getBean("userFactory");
        service.run();*/
        /**
         * 实例化工厂的方式获取bean
         */
        UserService service = (UserService) context.getBean("userFactory");
        service.run();
    }
}
